"use strict"

let menu_btn = document.querySelector(".menu_btn");
let menu = document.querySelector(".menu");
let profile = document.querySelector(".profile");
let close_menu = document.querySelector(".menu_close");
let close_pro = document.querySelector(".pro_close");
let drop = document.querySelectorAll(".gimc");
let drop_cont = document.querySelectorAll(".drop_down");
let down = document.querySelectorAll(".down_a");
let search = document.querySelector(".search");
let search_page = document.querySelector(".search_page");
let close_s = document.querySelector(".s_close");
let turn_log = document.querySelector(".turn_login");
let log_page = document.querySelector(".login");
let log_btn = document.querySelector(".btn_login");
let exit = document.querySelector(".exit");
var fl = false;
//个人页的划出-------
function menu_slide(){
	menu_btn.addEventListener("touchend",function(e){
		menu.style.left = 0+ "px";
		e.preventDefault();
	})
}
//个人页的关闭----------
function menu_close(){
	close_menu.addEventListener("touchend",function(e){
		menu.style.left = -100+"%";
		e.preventDefault();
	})
}

function dropdown(){
	for(let i=0;i<drop.length;i++){
		drop[i].addEventListener("click",function(){
		
			if(!fl){
				clos();
				drop_cont[i].style.display = "block";
				down[i].classList.add("down");
				fl=true;
			}else{
				drop_cont[i].style.display = "none";
				down[i].classList.remove("down");
				fl=false;
			}
//			for(let j=0;j<drop_cont.length;j++){
//				drop_cont[j].style.display = "none";
//				down[j].classList.remove("down");
//				clos();
//			}
//			drop_cont[i].style.display = "block";
//			down[i].classList.add("down");
			
		})
	}
}
function clos(){
	for(let k=0;k<drop.length;k++){
//		drop[k].addEventListener("click",function(){
//			if(drop_cont[k].style.display === "block"){
//				drop_cont[k].style.display = "none";
//				down[k].classList.remove("down");
//			}else{
//				drop_cont[k].style.display = "block";
//				down[k].classList.add("down");
//			}
//			
//		})
		drop_cont[k].style.display = "none";
		down[k].classList.remove("down");
	}
}

//打开搜索页-----------
function searchdown(){
	search.addEventListener("touchend",function(){
		search_page.style.top = 0 + "px";
	})
}
function searchclose(){
	close_s.addEventListener("touchend",function(){
		search_page.style.top = -100 + "%";
	})
}

//打开登录页===========
function turn_login(){
	turn_log.addEventListener("touchend",function(){
		log_page.style.display = "block";
	})
	
}
//登录====================
function login(){
	log_btn.addEventListener("click",function(){
		log_page.style.display = "none";
		profile.style.display = "block";
	})
}


//关闭个人中心页===============
function profile_close(){
	close_pro.addEventListener("touchend",function(){
//		profile.style.left = -100 +"%";
		profile.style.display = "none";
		menu.style.left = -100+"%";
	})
}

//退出个人中心页========================
function exit_pro(){
	exit.addEventListener("click",function(){
		profile.style.display = "none";
	})
}
menu_slide();
menu_close();
dropdown();
searchdown();
searchclose();
turn_login();
profile_close();
login();
exit_pro();

